package com.zbkj.crmeb.store.controller;

import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.store.request.ActivityProductEnrollRequest;
import com.zbkj.crmeb.store.request.ActivityProductSearchRequest;
import com.zbkj.crmeb.store.response.ActivityVerifyResponse;
import com.zbkj.crmeb.store.service.ActivityProductService;
import com.zbkj.crmeb.store.service.StoreProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 活动商品
 * @Description: 
 * @author duyb
 * @date 2022-11-10
 */
@RestController
@RequestMapping("api/admin/activity/product")
@Api(tags = "活动商品")
public class ActivityProductController {
    @Autowired
    ActivityProductService activityProductService;


    
    /**
     * 审核分页查询
     * @Description:
     * @author duyb
     * @param @param [ActivityManageRequest pageParamRequest]
     * @return CommonResult<Object>
     * @Date: 2022-11-10
     */
    @ApiOperation(value = "审核分页查询")
    @GetMapping("/verify/page")
    public CommonResult<Object> verifyPageEntity(@ModelAttribute ActivityProductSearchRequest request, @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<ActivityVerifyResponse> setUpResponseCommonPage = CommonPage.restPage(activityProductService.verifyPageEntity(request,pageParamRequest));
        return CommonResult.success(setUpResponseCommonPage);
    }

    /**
     * 活动商品分页查询
     * @Description:
     * @author duyb
     * @param @param [ActivityManageRequest pageParamRequest]
     * @return CommonResult<Object>
     * @Date: 2022-11-10
     */
    @ApiOperation(value = "活动商品分页查询")
    @GetMapping("/page")
    public CommonResult<Object> pageEntity(@ModelAttribute ActivityProductSearchRequest request,@ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<ActivityVerifyResponse> setUpResponseCommonPage = CommonPage.restPage(activityProductService.pageEntity(request,pageParamRequest));
        return CommonResult.success(setUpResponseCommonPage);
    }

    
    /**
     * 报名
     * @Description:  
     * @author duyb
     * @param @param activityProductEnrollRequest
     * @return CommonResult<Object>
     * @Date: 2022-11-10
     */
    @ApiOperation(value = "报名")
    @PostMapping("/save")
    public CommonResult<Object> save(@RequestBody ActivityProductEnrollRequest activityProductEnrollRequest) {
        return CommonResult.success(activityProductService.saveEntity(activityProductEnrollRequest));
    }

    /**
     * 批量审核
     * @Description:
     * @author duyb
     * @param @param productEnrollList
     * @return CommonResult<Object>
     * @Date: 2022-11-11
     */
    @ApiOperation(value = "批量通过")
    @PostMapping("/batch/verify")
    public CommonResult<Object> batchVerify(@RequestBody List<Integer> productEnrollList) {
        return CommonResult.success(activityProductService.batchVerify(productEnrollList));
    }

    /**
     * 审核
     * @Description:
     * @author duyb
     * @param @param ActivityProductEnrollRequest
     * @return CommonResult<Object>
     * @Date: 2022-11-11
     */
    @PostMapping("/verify")
    @ApiOperation("审核")
    public CommonResult<Object> verify(@RequestBody ActivityProductEnrollRequest request) {
        return CommonResult.success(activityProductService.verify(request));
    }
    
    /**
     * 根据id删除
     * @Description:  
     * @author duyb
     * @param @param id
     * @return CommonResult<Object>
     * @Date: 2022-10-27
     */
    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/{id}")
    public CommonResult<Object> del(@PathVariable("id") Integer id) {
        return CommonResult.success(activityProductService.removeById(id));
    }

}
